package pro.shushi.pamirs.hr.api.model.eam;

import pro.shushi.pamirs.boot.base.ux.annotation.field.UxWidget;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxDetail;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxForm;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTableSearch;
import pro.shushi.pamirs.hr.api.enums.BooleanConstantEnum;
import pro.shushi.pamirs.hr.api.enums.eam.UkCycTypeEnum;
import pro.shushi.pamirs.hr.api.model.eam.common.AbstractOrgBaseModel;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.IdModel;

import java.util.List;

// 模型中UX开头的注解(UxForm/UxTable/UxDetail等)可以不用写，都可在设计器中进行可视化配置; 代码里面写这些注解是为了默认页面的交互
@UxForm(grid = 3)
@UxDetail(grid = 3)
@Model.model(EamMtoolMtHd.MODEL_MODEL)
@Model(displayName = "工装保养项")
@Model.Advanced(table="eam_mtool_mt_hd",unique = {"orgCode, mmdCode,ukCycType"})
public class EamMtoolMtHd extends AbstractOrgBaseModel {

    public static final String MODEL_MODEL = "hr.simple.eamMtoolMtHd";

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field(displayName = "组织编码", required = true)
    private String orgCode;

//    @UxTableSearch.FieldWidget(@UxWidget())
//    @Field(displayName = "工装型号编码", required = true)
//    public String mmdCode;

    // ---------- 工装型号 ----------------------
    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.many2one
    @Field.Relation(relationFields = {"mmdCode"}, referenceFields = {"mmdCode"})
    @Field(displayName = "工装型号", required = true)
    private BsMtoolMd bsMtoolMd;

    @Field(displayName = "工装型号编码", invisible = true)
    private String mmdCode;

    @Field.String
    @Field.Related(related = {"bsMtoolMd", "mmdName"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "工装型号名称")
    private String mmdName;

    // ---------- 工装型号 ----------------------


    @Field.Enum(size='4')
    @Field(displayName = "保养类型", required = true,defaultValue = "1")
    public UkCycTypeEnum ukCycType;

    @Field.Enum(size='1')
    @Field(displayName = "启用", required = true, defaultValue = "y")
    public BooleanConstantEnum isValid;

    @Field.Text
    @Field(displayName = "备注")
    private String remark;

    @Field.one2many
    @Field.Relation(relationFields = {"orgCode", "mmdCode","ukCycType"}, referenceFields = {"orgCode", "mmdCode","ukCycType"})
    @Field(displayName = "保养项明细")
    private List<EamMtoolMtPj> eamMtoolMtPjs;


}
